<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta charset="utf-8" /></head>

<style type="text/css">
html, body {
padding: 0;
max-width: 900px;
height: 100%;
border: none;
background-color: #F4F8FD;
font-family:Verdana, Arial, Helvetica, sans-serif;
}
div.body{
	border: 1px solid #E0E4EC;
	background-color: #F4F8FD;
}
h1{
	text-align: center;
}
h3{
	text-align: left;
}
div.leftcolum {
float: left;
}
div.rightcolum {
float: right;
}
span.vline {
	border-left: thin solid #CDBFDC;
	border-right: thin solid #CDBFDC;
}
span.hlred {
	font-weight : bold;
	color : #FF0000;
}
table {
	width: 100%;
}
table.textwrap { 
	width: 1px;
	margin: 5px;
}
table.topsection{
	border: 1px solid #CDB;
	background-color: #DEC;
}
td.textleft { text-align: left; }
td.textright { text-align: right; }

SPAN.PermiPrefix { color: #008080 }
SPAN.DataPrefix { color: #22EEAA }
SPAN.CodeStruct { color: #CC00FF; font-weight: bold; }
SPAN.DataType { color: #10CC20 }
SPAN.StmtKey { color: #FF9900; font-weight: bold; }
SPAN.Comment { color: #0066FF; font-style: italic; }
SPAN.String { color: #FF0066 }
SPAN.Number { color: #FF0044 }
SPAN.Method { color: #448800 }
SPAN.SpecSymbol { color: #999900 }
.text_italic { font-style: italic; }
.text_bold { font-weight: bold; }
.text_delete { text-decoration: centerline; }
.text_underline { text-decoration: underline; }
.flushright{ text-align: right; }
.bold{ font-weight: bold; }
.vspace{ padding: 0.3em 0.3em; }
span.codeback{
	background-color: #cda;
}

TABLE.boardHeader {
	padding: 8px 2px;
	background-color: #D5EFDC;
	width: 100%;
}

div.hlcode {
	background-color: #E8F8F8;
	margin: 5px;
	padding : 5px;
	width: 90%;
	margin-left	: 5%;
	margin-right : 5%;
	border: 2px dashed #bdc;
}
TABLE.outputTable {
	background-color: #D8FEFE;
	width: 90%;
	margin-left	: 5%;
	margin-right : 5%;
}
.sdmltable {
	background-color: #F8E8FB;
	width: 90%;
	margin-left	: 5%;
	margin-right : 5%;
	border: 1px solid #CCCCCC;
}
.docTableRow {
	padding: 10px 10px;
	background-color: #F4EEFB;
}
.docTableCell {
	background-color: #F8EEFB;
	padding-right  : 10px;
	padding-top	: 2px;
	padding-left   : 10px;
	padding-bottom : 2px;
	border: 1px solid #CCCCCC;
}

</style>
<body><div class="body">
<h2>Exception Handling in Dao</h2>
 <br/>
Dao exceptions are organized into hierarchal structured classes.
The base class is <span class=text_bold> Exception</span> ,
<div class="hlcode">
<span class=CodeStruct>class</span>&thinsp; Exception<br/><span class=SpecSymbol>{</span><br/>&thinsp; &thinsp; <span class=CodeStruct>routine</span>&thinsp; Exception<span class=SpecSymbol>(</span>&thinsp; content=<span class=String>''</span>&thinsp; <span class=SpecSymbol>)</span><span class=SpecSymbol>{</span>&thinsp; Content&thinsp; =&thinsp; content&thinsp; <span class=SpecSymbol>}</span><br/>&thinsp; &thinsp; <span class=PermiPrefix>protected</span><br/>&thinsp; &thinsp; &thinsp; &thinsp; var&thinsp; Rout&thinsp; =&thinsp; <span class=String>''</span>;<br/>&thinsp; &thinsp; &thinsp; &thinsp; var&thinsp; File&thinsp; =&thinsp; <span class=String>''</span>;<br/>&thinsp; &thinsp; &thinsp; &thinsp; var&thinsp; FromLine&thinsp; =&thinsp; <span class=Number>0</span>;<br/>&thinsp; &thinsp; &thinsp; &thinsp; var&thinsp; ToLine&thinsp; =&thinsp; <span class=Number>0</span>;<br/>&thinsp; &thinsp; <span class=PermiPrefix>public</span><br/>&thinsp; &thinsp; &thinsp; &thinsp; var&thinsp; Name&thinsp; &thinsp; =&thinsp; <span class=String>'Exception'</span>;<br/>&thinsp; &thinsp; &thinsp; &thinsp; var&thinsp; Content&thinsp; :&thinsp; any&thinsp; =&thinsp; <span class=String>'undefined exception'</span>;<br/><span class=SpecSymbol>}</span></div>
 
Currently supported classes are the following:

<table class="sdmltable">
<tr><th> Class</th><th> Exception Type</th></tr>
<tr class=docTableRow><td class=docTableCell> Exception</td><td class=docTableCell> Any</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.None</td><td class=docTableCell> None</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Any</td><td class=docTableCell> Any or none</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error</td><td class=docTableCell> Any error</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Warning</td><td class=docTableCell> Any warning</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error.Field</td><td class=docTableCell> invalid field accessing</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error.Field.NotExist</td><td class=docTableCell> field not exist</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error.Field.NotPermit</td><td class=docTableCell> field not permit</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error.Float</td><td class=docTableCell> invalid floating point operation</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error.Float.DivByZero</td><td class=docTableCell> division by zero</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error.Float.OverFlow</td><td class=docTableCell> floating point overflow</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error.Float.UnderFlow</td><td class=docTableCell> floating point underflow</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error.Index</td><td class=docTableCell> invalid index</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error.Index.OutOfRange</td><td class=docTableCell> index out of range</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error.Key</td><td class=docTableCell> invalid key</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error.Key.NotExist</td><td class=docTableCell> key not exist</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error.Param</td><td class=docTableCell> invalid parameter list for the call</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error.Syntax</td><td class=docTableCell> invalid syntax</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error.Type</td><td class=docTableCell> invalid variable type for the operation</td></tr>
<tr class=docTableRow><td class=docTableCell> Exception.Error.Value</td><td class=docTableCell> invalid variable value for the operation</td></tr>
</table>
 
New exception classes can be derived from the above classes.<br/><br/>
Any running time error will raise a proper exception instance.
User-defined exception can be raised by using <span class=text_bold> raise</span>  statement.
Exceptions can be rescued by a block of code after a <span class=text_bold> rescue</span>  statement
The exception handling syntax is the following:
<div class="hlcode">
stmt_tryrescue&thinsp; <span class=CodeStruct>::=</span>&thinsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp; <span class=String>'try'</span>&thinsp; <span class=String>'{'</span>&thinsp; stmt_block<br /> &nbsp;&nbsp;&nbsp;&nbsp; <span class=SpecSymbol>{</span>&thinsp; <span class=String>'}'</span>&thinsp; <span class=String>'rescue'</span>&thinsp; <span class=SpecSymbol>[</span>&thinsp; <span class=String>'('</span>&thinsp; expr&thinsp; <span class=String>')'</span>&thinsp; <span class=SpecSymbol>]</span>&thinsp; <span class=String>'{'</span>&thinsp; stmt_block&thinsp; <span class=SpecSymbol>}</span><span class=DataType>*</span>&thinsp; <br /> &nbsp;&nbsp;&nbsp;&nbsp; <span class=String>'}'</span></div>
 
where <span class=text_italic> expr</span>  is a list of exception class(es).
If there is no <span class=text_italic> expr</span>  following <span class=text_bold> rescue</span> , any exception will be rescued.
There can be multiple <span class=text_bold> rescue</span>  statements in a try-rescue block.
The raised exceptions will be checked against the exception classes presented in
each of the <span class=text_bold> rescue</span>  statement, if there is a matching, the corresponding code
block is executed, and the rescued exceptions can be accessed in a global list named
<span class=text_bold> exceptions</span> . In the same try-rescue block different <span class=text_bold> rescue</span>  statements
can be used to handle different exceptions. <br/><br/>
If all <span class=text_bold> rescue</span>  statements have been tried and there
is still un-rescued exception(s), the current function is aborted and the exceptions(s)
is raised to its caller, if there is; otherwise, the program is aborted with
the values of the un-rescued exceptions printed out.
In a <span class=text_bold> rescue</span>  statement, one may modify exection condition, and use <span class=text_bold> retry</span>  to
invoke the codes in try block.<br/><br/>
Examples,
<div class="hlcode">
try<span class=SpecSymbol>{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp; raise&thinsp; Exception.Error<span class=SpecSymbol>(</span>&thinsp; <span class=String>"error test"</span>&thinsp; <span class=SpecSymbol>)</span>,&thinsp; Exception.Warning<span class=SpecSymbol>(</span>&thinsp; <span class=String>"warning test"</span>&thinsp; <span class=SpecSymbol>)</span>,<br/>&nbsp;&nbsp;&nbsp;&nbsp; Exception<span class=SpecSymbol>(</span>&thinsp; <span class=String>"exception"</span>&thinsp; <span class=SpecSymbol>)</span>;<br/><span class=SpecSymbol>}</span>rescue<span class=SpecSymbol>(</span>&thinsp; Exception.Error,&thinsp; Exception.Warning&thinsp; <span class=SpecSymbol>)</span><span class=SpecSymbol>{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp; <span class=Method>stdio.println</span><span class=SpecSymbol>(</span>&thinsp; exceptions&thinsp; <span class=SpecSymbol>)</span>;<br/><span class=SpecSymbol>}</span>rescue<span class=SpecSymbol>{</span><br/>&nbsp;&nbsp;&nbsp;&nbsp; <span class=Method>stdio.println</span><span class=SpecSymbol>(</span>&thinsp; <span class=String>"rescued"</span>&thinsp; <span class=SpecSymbol>)</span>;<br/><span class=SpecSymbol>}</span></div>
<br clear=all />
</div></body></html>
